package xj.meta;

/**********************************************************************************
 *
 * @author Xiaoping Jia
 * @version 0.2
 *
 * Created on: 2005/05/01
 * Requires: J2SE 5.0
 *
 **********************************************************************************/

import java.io.PrintWriter;
import java.util.List;
import java.util.Set;
import java.util.UUID;

public interface ModelElement extends Mark, Cloneable {

  public Object clone() throws CloneNotSupportedException;

  public UUID getUUID();

  public String getId();

  public void setId(String id);

  public String getElementName();

  public void setElementName(String name);

  public String getRole();

  public void setRole(String role);

  public Set<String> getRoleNames();

  public ModelElement getOwner();

  public void setOwner(ModelElement owner);

  public List<ModelElement> getOwnedElements();

  public void addOwnedElement(ModelElement e);

  public void addOwnedElement(ModelElement e, String role);

  public void setOwnedElements(String role, List<ModelElement> l);

  public void setOwnedElement(String role, ModelElement e);

  public void removeOwnedElement(ModelElement e);

  public void removeOwnedElements(String role);

  public void deconstruct();

  /* whether the element should be deconstructed */
  public boolean isDestructable();

  public void setDestructable(boolean b);

  /* whether the element should be preserved in deconstruction */
  public boolean isPreserved();

  public void setPreserved(boolean b);

  public List<ModelElement> getElements(String role);

  /* e is a child of this */
  public boolean isChild(ModelElement e);

  /* e is a descendant of this */
  public boolean isDescendant(ModelElement e);

  /* e is an ancestor of this */
  public boolean isAncestor(ModelElement e);

  public Object getAttribute(String attr);

  public void setAttribute(String attr, Object value);

  public Set<String> getAllAttirbuteNames();

  public Set<Annotation> getAnnotations();

  public void addAnnotations(List<Annotation> alist);

  public void addAnnotation(Annotation a);

  public Annotation getAnnotation(String name);

  public void removeAnnotation(String name);

  public Set<Link> getLinks();

  public void addLinks(List<Link> alist);

  public void addLink(Link a);

  public void addLink(String name, String link);

  public Link getLink(String name);

  public void removeLink(String name);

  public void removeAllLinks();

  public void exportXML(PrintWriter out, int level);

  public void exportXML(PrintWriter out, int level, String role);

  // New Added Methods by Frank
  public Set<String> getAllRoleNames();

  public ModelElement getOwnedElement(int p);

  public void addOwnedElements(String role, List<ModelElement> l);

  public boolean hasOwnedElement(ModelElement e);

  public boolean hasOwnedElement(String role);

  public void insertOwnedElementAt(ModelElement e, String role, int p);

  public void replaceOwnedElement(String newRole, ModelElement newElement,
				  ModelElement oldElement);

  public void replaceOwnedElement(ModelElement newElement, String role);

  public void replaceOwnedElement(String role, ModelElement newElement, int p);

  public void removeAttribute(String name);

  public int getLevel();

  public String getRoleInOwner();

  public boolean getShowMetaDetail();

  public void setShowMetaDetail(boolean b);

  public Mark getMark();

  public void setMark(Mark mark);

  public void visitPreOrder(ModelElementVisitor visitor, Object data);

  public void visitPreOrder(ModelElementVisitor visitor, Object data,
			    boolean useMetaDetailAttribute);

  public void visitPostOrder(ModelElementVisitor visitor, Object data);

  public Object accept(ModelElementVisitor visitor, Object data);

}
